<!DOCTYPE html>
<!-- saved from url=(0042)https://sc.myuserhub.com/portal/pswdchange -->
<html>
{include file="public/head"}
<body>
{include file="public/nav"}

<!--<div class="container">-->
<div class="rowHeader">
    <div class="container">
        <div class="row">
            <div class="col-lg-6 col-md-6" style="text-align:left">
                <h1>

                    欢迎 <span class="userName">{$UserInfo.username}</span>

                    <span class="label label-success lb-sm" style="vertical-align: middle;">通过审核</span>


                </h1>
            </div>
            <!--End collumn-->

            <div class="col-lg-6 col-md-6 pageTitleRight">
                <h1 class="pull-right">投资</h1>
            </div>
            <!--End collumn-->

        </div>
        <!--End Row-->
    </div>
    <!--End container-->
</div>
<!--End Row-->

<div class="container">
    <div class="row mainRow">

        <!--菜单栏-->
        {include file="public/menu"}
        <!--End column-->
        <div class="col-lg-9 col-md-12 col-sm-12 mainContent">



            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
                        投资 </h4>
                </div>
                <div class="panel-body">
                    <form method="post">
                        <div class="form-group" id="">
                            <label class="col-lg-4 col-md-4 control-label" for="balance">账户余额 <span
                                    class="redStar">*</span></label>
                            <div class="col-lg-8 col-md-8">
                                <input type="text" class="form-control" id="balance" value="{$UserInfo.balance_1|floatval}" readonly disabled placeholder="">
                                <span class="help-block helpBlockOldPassword"></span>
                            </div>
                            <!--End column-->
                        </div>
                        <div class="form-group" id="">
                            <label class="col-lg-4 col-md-4 control-label" for="balance">钱包类型 <span
                                    class="redStar">*</span></label>
                            <div class="col-lg-8 col-md-8">
                                <select name="pay_type" id="pay_type" class="form-control">
                                    <option value="1" address='{$address1}'>Omni</option>
                                    <option value="2" address='{$address2}'>TRC20</option>
                                    <option value="3" address='{$address3}'>ERC20</option>
                                </select>
                                <span class="help-block helpBlockOldPassword"></span>
                            </div>
                            <!--End column-->
                        </div>
                        <div class="form-group" id="">
                            <label class="col-lg-4 col-md-4 control-label" for="balance">钱包地址 <span class="redStar">*</span></label>
                            <div class="col-lg-8 col-md-8">
                                <div class="input-group">
                                    <select name="" id="address" class="form-control" >

                                    </select>
                                    <div class="input-group-addon copy_address" data-clipboard-text="">复制</div>
                                </div>

                                <span class="help-block helpBlockOldPassword"></span>
                            </div>
                            <!--End column-->
                        </div>
                        <!--Input Password Type-->
                        <div class="form-group" id="">
                            <label class="col-lg-4 col-md-4 control-label" for="amount">投资金额 <span
                                    class="redStar">*</span></label>
                            <div class="col-lg-8 col-md-8">
                                <input type="number" id="amount" name="amount" class="form-control"
                                       placeholder="至少1000U" value="1000" step="100" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''">
                                <span class="help-block helpBlockOldPassword"></span>
                            </div>
                            <!--End column-->
                        </div>
                        <!--End Password Type-->
                        <div class="form-group" id="">
                            <label class="col-lg-4 col-md-4 control-label" for="time">投资时间 <span
                                    class="redStar">*</span></label>
                            <div class="col-lg-8 col-md-8">
                                <input type="text" class="form-control" id="time" value="12个月" readonly disabled placeholder="">
                                <span class="help-block helpBlockOldPassword"></span>
                            </div>
                            <!--End column-->
                        </div>
                        <!--Input Old Pass -->
                        <div class="form-group" id="groupOldPassword">
                            <label class="col-lg-4 col-md-4 control-label" for="password">密码 <span
                                    class="redStar">*</span></label>
                            <div class="col-lg-8 col-md-8">
                                <input type="password" id="password" name="password" class="form-control"
                                       placeholder="">
                                <span class="help-block helpBlockOldPassword"></span>
                            </div>
                            <!--End column-->
                        </div>
                        <!--End Old Pass-->
                        <div class="panel-heading">请上传转账凭证 </div>
                        <div class="panel-body">
                            <label for="upload">
                                <a class="btn btn-default btnWhiteWithBlue"> 请上传转账凭证</a>
                                <input type="file" id="upload" style="display: none">
                                <input type="hidden" name="img" id="img">
                            </label>
                            <img src="" id="img_show" alt="">
                        </div>
                        <button type="submit" id="deposit" class="btn btn-primary greenBtn pull-right" style="margin-right: 15px;">提交 </button>

                    </form>
                </div>
                <!--End panel body-->
            </div>
            <!--End panel-->


        </div>
        <!--End column-->

    </div>
    <!--End row-->
</div>
<!--End container-->

{include file="public/foot"}
</body>
<script src="/static/Admin/layer/layer.js"></script>
<script>
    var copyBtn2 = new ClipboardJS('.copy_address');
    copyBtn2.on("success",function(e){
        layer.msg('复制成功');
        e.clearSelection();
    });
    copyBtn2.on("error",function(e){
        //复制失败；
        layer.msg('复制失败');
    });
    $("#pay_type").change(function () {
        var address = $("#pay_type option:selected").attr('address')
        // $("#address").val(address)
        changeADD()
    })
    changeADD()
    function changeADD(){
        var address = $("#pay_type option:selected").attr('address')
        // var html = JSON.stringify(address)
        // console.log(html)
        var arr = JSON.parse(address)
        console.log(arr)
        var str = ``;
        for (var i =0;i<arr.length;i++){
            str += `<option value="${arr[i].id}" address="${arr[i].address}">${arr[i].address}</option>`;
        }
        $("#address").html(str)
        if (arr.length > 0){
            $(".copy_address").attr('data-clipboard-text',arr[0].address)
        }
    }
    $("#address").change(function () {
        var address = $("#address option:selected").attr('address')
        $(".copy_address").attr('data-clipboard-text',address)
    })
    //ajax异步图片上传
    $('#upload').change(function(){
        //图片对象
        let that = $(this);
        var formData = new FormData();
        formData.append("image", that[0].files[0]);

        // 上传设置
        $.ajax({
            // 规定把请求发送到那个URL
            url: "{:url('Assets/forUpload')}",
            type: "post",            // 请求方式
            dtaType: 'json',
            data: formData,//传值就传fd对象了
            processData:false,  //告诉jQuery不要处理数据
            contentType: false,  //告诉jQuery不要设置contentType
            // 请求成功时执行的回调函数
            success: function (data) {
                if(data.status == 1)
                {
                    $("#img_show").attr('src',data.message);
                    $("#img").val(data.message);
                }
                else
                {
                    layer.msg(data.message);
                }
            }
        });
    });
    var flag = 1;
    $("#deposit").click(function (e) {
        e.preventDefault();
        if (!flag){
            return  false
        }
        var amount = $("#amount").val();
        if (amount == '' || amount <= 0 || isNaN(amount)){
            layer.msg('请输入投资数量');
            return false
        }
        if (parseFloat(amount) < 1000){
            layer.msg('投资最少1000U');
            return false
        }
        var pay_type = $("#pay_type").val()
        var img = $("#img").val()
        var password = $("#password").val()
        var that = $(this)
        that.attr('disabled',true)
        flag = 0;
        $.ajax({
            type:"post",
            dataType:"json",
            data:{amount:amount,password:password,pay_type:pay_type,img:img},
            url:"{:url('Finance/Deposit')}",
            success:function (data) {
                if (data.status == 1){
                    layer.msg(data.message,{time:1500},function () {
                        window.location.href = data.url
                    })
                }else {
                    layer.msg(data.message,{time:1500},function () {
                        that.removeAttr('disabled')
                        flag = 1;
                    })
                }
            }
        })
    })
</script>
</html>
